package xyz.lilei23.framework.utils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 动态代理注解判断工具
 * @author jack
 * @date 31/07/2021 16:20
 * @version 1.0
 **/
public class DynamicProxyAnnotationUtil {

	public static Annotation findAnnotationFromProxy(Class<?> cusAnnotation, Object target, Method method) throws NoSuchMethodException {
		Annotation[] annotations = target.getClass().getSuperclass().getMethod(method.getName(), method.getParameterTypes()).getAnnotations();
        return Arrays.stream(annotations).filter(annotation -> annotation.annotationType().isAssignableFrom(cusAnnotation)).findFirst().orElse(null);
	}
}